<template>
  <div class="usual3">
    <el-card class="cardOut2">

      <div class="gengxinanniu">
        <el-button type="primary"  @click="dialogFormVisible = true">报销申请</el-button>

        <el-dialog title="新增信息" :visible.sync="dialogFormVisible">
          <el-form :model="form2">
<!--            <el-form-item label="职位" :label-width="formLabelWidth">-->
<!--              <el-input v-model="form2.position" autocomplete="off"></el-input>-->
<!--            </el-form-item>-->
            <el-form-item label="基本薪资" :label-width="formLabelWidth">
              <el-input v-model="form2.basicsalary" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="奖金" :label-width="formLabelWidth">
              <el-input v-model="form2.jiangjin" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="报销" :label-width="formLabelWidth">
              <el-input v-model="form2.baoxiao" autocomplete="off"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="cancel()">取消添加</el-button>
            <el-button type="primary" @click="Submit('form2')">确定添加</el-button>
          </div>
        </el-dialog>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "usual3",
  data(){
    /* 定义初始化变量 */
    return{
      dialogFormVisible:false,
      user:{},
      form2:{
        // username:this.user.username,
        id:'',
        position:'',
        basicsalary:'',
        jiangjin:'',
        baoxiao:'',
        status1:'',
        username:''
      }

    }
  },
//put请求发送方式
  //   username:this.form.username
  // this.$axios.put('/admin/updateException'+this.form+'/'
  //     +this.user.id).then(res=>{
  //   this.$message.success("提交成功")
  //   window.alert("提交成功")t
  // })
  /* 定义事件函数 */
  methods:{
    Submit(form2){
      this.form2.username = this.user.username
      this.$axios.post('/admin/updateException',this.form2).then(res=>{
        if(res.data.code===200){

          this.$message.success("提交成功")
          this.form2=[]
          this.dialogFormVisible=false
          // window.alert("提交成功")
        }else{
          this.$message.error("提交失败")
        }

      })
    }
  },
  /* vue的生命周期函数
     当页面加载完毕就会执行created里面的函数
  */
  created() {
let user=JSON.parse(sessionStorage.getItem('user')||'{}')
    if(user!=null){
      this.user=user
    }
  }
}
</script>

<!-- scoped此属性可以防止当前页面的样式不会影响其他页面样式 -->
<style scoped>
@import url("Usual3.css");
</style>